#include<iostream>
using namespace std;
const int N = 1e6+10;
typedef long long LL;
LL fa[N];

struct node
{
	LL x;
	LL y;
	LL z;
}a[N];
LL find(LL x)
{
	if (x == fa[x]) return x;
	else return fa[x] = find(fa[x]);
}

void merge(LL x, LL y)
{
	fa[find(x)] = find(y);
}
LL calc(LL u, LL v)
{
	return (a[u].x - a[v].x) * (a[u].x - a[v].x) + (a[u].y - a[v].y) * (a[u].y - a[v].y) + (a[u].z - a[v].z) * (a[u].z - a[v].z);
}
int main()
{
	int T = 0;

	cin >> T;
	while (T--)
	{
		LL n = 0, h = 0, r = 0;
		cin >> n >> h >> r;
		//初始化
		for (int i = 0;i <= n + 1;i++) fa[i] = i;
		for (int i = 1;i <= n;i++)
		{
			cin >> a[i].x >> a[i].y >> a[i].z;
			if (a[i].z <= r) merge(0, i);
			if (a[i].z + r >= h) merge(i, n + 1);//一定注意这个地方不走else if因为有可能一个洞把上下都连起来了
			//这个for循环不是else里的，是必须走的
			for (int j = 1;j < i;j++)
			{
				LL c = 4 * r * r;
				if (calc(j, i) <=c)//这个4千万别忘记
				{
					merge(j, i);
				}
			}
		}
 		if (find(0) == find(n + 1)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}